package com.ruoyi.wechat.api;


import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.degree.domain.BizSchools;
import com.ruoyi.degree.domain.BizSchoolsProfessions;
import com.ruoyi.degree.domain.BizSchoolsProfessionsClasses;
import com.ruoyi.degree.service.IBizSchoolsProfessionsClassesService;
import com.ruoyi.degree.service.IBizSchoolsProfessionsService;
import com.ruoyi.degree.service.IBizSchoolsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wxapi/userprofession")
@Api(tags = "专业API", description = "专业相关接口")
public class WechatUserProfessionApi {

    @Autowired
    private IBizSchoolsProfessionsService bizSchoolsProfessionsService;
    @Autowired
    private IBizSchoolsService bizSchoolsService;
    @Autowired
    private IBizSchoolsProfessionsClassesService bizSchoolsProfessionsClassesService;
    @ApiOperation("根据ID和学校ID获取专业详细信息")
    @GetMapping("getProfession/{id}/{schoolId}")
    @Anonymous
    public AjaxResult getProfession(
            @ApiParam(value = "id", required = true) @PathVariable Long id,
            @ApiParam(value = "schoolId", required = true) @PathVariable Long schoolId) {
        BizSchoolsProfessions bizSchoolsProfessions = bizSchoolsProfessionsService.selectBizSchoolsProfessionsById(id);
        BizSchools schools = bizSchoolsService.selectBizSchoolsById(schoolId);
        List<BizSchoolsProfessionsClasses>  professionsClasses =bizSchoolsProfessionsClassesService.selectBizSchoolsProfessionsClassesByProfessionId(id);
        // 你可以根据需要将 bizSchools 也返回
        return AjaxResult.success()
                .put("schools", schools)
                .put("profession", bizSchoolsProfessions)
                .put("professionClasses",professionsClasses);
    }

    //获取专业列表
    @ApiOperation("获取专业列表")
    @GetMapping("/getProfessionList")
    @Anonymous
    public AjaxResult getProfessionList(@RequestParam Long schoolId,@RequestParam String teachLanguage, @RequestParam String openingDate    ) {
        BizSchoolsProfessions query = new BizSchoolsProfessions();
        query.setSchoolId(schoolId);
        query.setLanguages(teachLanguage);
        query.setOpeningDates(openingDate);
        List<BizSchoolsProfessions> bizSchoolsProfessionsList = bizSchoolsProfessionsService.selectBizSchoolsProfessionsList(query);
        return AjaxResult.success(bizSchoolsProfessionsList);
    }

}
